package cn.aihongbo.kmp.data.repository

import cn.aihongbo.kmp.base.net.HNet
import cn.aihongbo.kmp.data.API_URL_HBC_GET_BASE_DATA_DIY
import cn.aihongbo.kmp.data.API_URL_HBC_GET_CITIES_BY_COUNTRY
import cn.aihongbo.kmp.data.API_URL_HBC_GET_CITIES_SEARCH
import cn.aihongbo.kmp.data.bean.CitiesBaseDiy
import cn.aihongbo.kmp.data.bean.CitiesByCountryBean
import cn.aihongbo.kmp.data.bean.CityBean
import kotlinx.coroutines.flow.Flow

class CityRepository {

    /**
     * 获取热门推荐城市
     */
    fun getCitiesByCountry(): Flow<CitiesByCountryBean?> = HNet.ins.get(
        API_URL_HBC_GET_CITIES_BY_COUNTRY, mutableMapOf(Pair("limit", "30"), Pair("offset", "0"))
    )

    /**
     * 获取全球大洲和国家城市
     */
    fun getBaseDataDiy(): Flow<List<CitiesBaseDiy?>> = HNet.ins.get(
        API_URL_HBC_GET_BASE_DATA_DIY
    )

    /**
     * 关键字搜索城市
     */
    fun getCitiesSearch(keyword: String): Flow<List<CityBean?>> = HNet.ins.get(
        API_URL_HBC_GET_CITIES_SEARCH,
        mutableMapOf(Pair("keyword", keyword), Pair("limit", "100"), Pair("offset", "0"))
    )

}